0
1
2
3
4
Table of Contents
A
B
C
D
asdpjaspdi jasd asdj apisdj apisd
Table of Contents
A
B
C
D
psdjpai djpaidjw
aidj pwaidj apwdij awdp
jaspid jawpidjwpi djw
asdas dad
Table of Contents
A
B
C
D
asd asdas d
d ajwdpiw jdpawidj pw d
Theorem 1 (ASD) aspdjaspid jsapi d.
See Theorem 1.
Table of Contents
A
B
C
D
%matplotlib inline
import numpy as np
import torch
from torch import nn
from ipywidgets import interactive
import matplotlib.pyplot as plt
m = 16
W1 = nn.Linear(1,m)
W1.weight.requires_grad = False
W2 = nn.Linear(m,m)
W2.weight.requires_grad = False
W2.bias.requires_grad = False
Wn = nn.Linear(m,m)
Wn.weight.requires_grad = False
sigR = nn.ReLU()
sigS = nn.Sigmoid()
Net = nn.Sequential(
W1, sigR,
nn.Linear(m,m), sigR,
W2, sigR,
nn.Linear(m,m), sigR,
Wn, sigR,
nn.Linear(m,1),
)
def f(w11=2.0, w21=-1.0, b21=1, wn1=2.0, b=0.0):
W1.weight[0,0] = torch.tensor([w11])
W2.weight[0,0] = torch.tensor([w21])
W2.bias[0] = torch.tensor([b21])
Wn.weight[0,0] = torch.tensor([wn1])
plt.figure(2)
x = np.linspace(-16, 16, num=600)
y = torch.zeros_like(torch.zeros(len(x)))
x_torch = torch.from_numpy(x).to(torch.float32)
# np.linspace(-10, 10, num=100000)
for j in range(len(x_torch)):
y[j] = Net(x_torch[j:j+1])
y = y.detach().numpy() + b
# print(x[:16])
print(y[:16])
plt.plot(x, y)
plt.ylim(-1, 1)
plt.show()
interactive_plot = interactive(f, w11 = (-10.0, 10.0),
w21 = (-10.0, 10.0),
b21 = (-20.0, 20.0),
wn1 = (-10.0, 10.0),
b = (-20.0, 20.0)
)
output = interactive_plot.children[-1]
output.layout.height = '500px'
interactive_plot